/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package rg1collectiondemo;


import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Stack;
import java.util.TreeMap;
import java.util.TreeSet;

/**
 *
 * @author apple
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        Stack<Integer> list1=new Stack<>();
        list1.add(23);
        list1.add(17);
        list1.add(66);
        list1.add(39);
        list1.add(14);
        list1.set(3, 59);
        list1.add(36);
        System.out.println(list1.get(3));
        list1.pop();
        list1.push(44);
        Collections.sort(list1);
        CollectionForEach.show(list1);
        
        TreeSet<Integer> set1=new TreeSet<>();   //自排序
        set1.add(23);
        set1.add(17);
        set1.add(66);
        set1.add(39);
        set1.add(14);
        CollectionForEach.show(set1);
        
        HashSet<Integer> set2=new HashSet<>();
        set2.add(23);
        set2.add(17);
        set2.add(66);
        set2.add(39);
        set2.add(14);
        CollectionForEach.show(set2);
        
        HashMap<Integer,String> map1=new HashMap<>();
        map1.put(23, "aaa23");
        map1.put(17, "aaa17");
        map1.put(66, "aaa66");
        map1.put(39, "aaa39");
        map1.put(14, "aaa14");
        System.out.println(map1.get(39));
        CollectionForEach.show(map1.keySet());
        CollectionForEach.show(map1.values());
        CollectionForEach.show(map1);
    }
    
}
